package com.xm.controller;

import com.github.pagehelper.PageInfo;
import com.xm.pojo.*;
import com.xm.service.MemberDynamicinfoService;
import com.xm.service.MemberEssentialinfoService;
import com.xm.service.MemberMedicalhistoryService;
import com.xm.util.WaterNumberGeneratorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
//@RequestMapping("aa")
public class MemberDataController {

    @Autowired
    MemberEssentialinfoService essentialinfoService;
    @Autowired
    MemberDynamicinfoService dynamicinfoService;
    @Autowired
    MemberMedicalhistoryService medicalhistoryService;

    @RequestMapping("/insertMemberinfo")
    public boolean insertMemberinfo(@RequestBody Memberinfo memberinfo){
        System.out.println(memberinfo);
        return essentialinfoService.insertMemberinfoService(memberinfo)>0;
    }

    @RequestMapping("/insertMemberDynamicinfo")
    public boolean insertMemberDynamicinfo(@RequestBody MemberDynamicinfo dynamicinfo){
        System.out.println(dynamicinfo);
        return dynamicinfoService.insertMemberDynamicinfoService(dynamicinfo)>0;
    }

    @RequestMapping("/insertMemberMedicalhistory")
    public boolean insertMemberMedicalhistory(@RequestBody MemberMedicalhistory medicalhistory){
        System.out.println(medicalhistory);
        return medicalhistoryService.insertMemberMedicalhistoryService(medicalhistory)>0;
    }

    @RequestMapping("/insertMemberfiles")
    public boolean insertMemberfiles(@RequestBody Memberfiles memberfiles){
        System.out.println(memberfiles);
        return essentialinfoService.insertMemberfilesService(memberfiles)>0;
    }

    @RequestMapping("/deleteMemberEssentialinfo")//删除基本信息
    public boolean deleteMemberEssentialinfo(String member_id){
        System.out.println(member_id);
        return essentialinfoService.deleteMemberEssentialinfoService(member_id)>0;
    }

    @PostMapping("/updateMemberEssentialinfo")//修改基本信息
    public boolean updateMemberEssentialinfo(Memberfiles memberfiles){
        return essentialinfoService.updateMemberEssentialinfoService(memberfiles)>0;
    }

    @RequestMapping("/queryMemberEssentialinfoList")//查询基本信息
    public PageInfo<Memberfiles> queryEssentialinfoList(@RequestBody PageVo<Memberfiles> pageVo){
        return essentialinfoService.queryEssentialinfoListService(pageVo);
    }

    @RequestMapping("/queryOneDynamicinfo")//查询动态信息
    public MemberDynamicinfo queryOneDynamicinfo(String member_id){
        return dynamicinfoService.queryOneService(member_id);
    }

    @RequestMapping("/queryOneMedicalhistory")//查询病史
    public MemberMedicalhistory queryOneMedicalhistory(String member_id){
        return medicalhistoryService.queryOneService(member_id);
    }

    @PostMapping("/queryMemberEssentialinfoAll")
    public List<Memberfiles> queryEssentialinfoAll(){
        return essentialinfoService.queryEssentialinfoAllService();
    }
}
